package servlet;

import model.Goods;
import service.GoodsService;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet(name = "goods_off", urlPatterns = "/goods_off")
public class GoodsOffServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        GoodsService gService = new GoodsService();
        int goodsid = Integer.parseInt(request.getParameter("id"));
        Goods g = gService.getGoodsById(goodsid);
        g.setIs_removed(true);
        gService.update(g);
        response.sendRedirect(request.getContextPath() + "/history_goods_publish?is_removed=0");
//        request.getRequestDispatcher("/history_goods_publish.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}